<template>
	<view>
		<uni-view class="cu-list menu-avatar" v-for="(item,index) in docMsg" :key="index">
		  <uni-view class="cu-item">
		    <uni-view class="cu-avatar round lg"
		      style='background-image: url(../../static/me/head.png);'>
		    </uni-view>
		    <uni-view class="content">
		      <uni-view class="text-black text-m">
		        <uni-text class="text-cut"><span style="font-weight:bold;">{{item.doctorName}}</span></uni-text>
		        <uni-view class="cu-tag round bg-orange" style="height: 20px;margin-left: 5px;">{{item.levelName}}</uni-view>
				<uni-view class="cu-tag round bg-blue" style="height: 20px;margin-left: 5px;">{{item.deptName}}</uni-view>
		      </uni-view>
		      <uni-view class="text-black text-sm flex">
		        <uni-text class="text-cut">
		          <span>{{item.orgName}}</span>
		        </uni-text>
		      </uni-view>
		    </uni-view>
		    <uni-view class="action">
		      <uni-view class="text-grey text-m"><span @click="selectAndBack(index)">选择 ></span></uni-view>
		    </uni-view>
		  </uni-view>
		</uni-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				docMsg1:[
					{
						doctor_id:1,
						doctor_name:'test1',
						org_name:'机构1',
						dept_name:'呼吸内科',
						level_name:'主任',
						avatar_url:''
					},
					{
						doctor_id:2,
						doctor_name:'test2',
						org_name:'机构2',
						dept_name:'科室2',
						level_name:'员工',
						avatar_url:''
					}
				],
				docMsg:''
			}
		},
		methods: {
			selectAndBack(index){
				let pages = getCurrentPages();
				let nowPage = pages[ pages.length - 1];  //当前页页面实例
				let prevPage = pages[ pages.length - 2 ];//上一页面
				prevPage.$vm.docMsg = this.docMsg[index];
				uni.navigateBack({
					delta:1
				});
			}
		},
		onLoad() {
			uni.request({
				url: 'http://121.43.172.59:8080/doctor/listall', //仅为示例，并非真实接口地址。
				/*data: {//参数
						rawData: rawData,
						code: loginRes.code
					},
				header: {
						'content-type': 'hello' ,//自定义请求头信息
                          "token":"hfhdsjkfhsdjkfhsjkdf",
					},*/
                method:'GET',//请求方式  或GET，必须为大写
				success: res => {
					
						console.log('返回', res.data);
						this.docMsg=res.data;
							}
				});
                fail:res =>{
                    console.log("请求失败");
                }
		}
	}
</script>

<style>

</style>
